package com.xinchen.ssh.demo.core.entity.page;

import java.io.Serializable;

/**
 * Description：
 *
 * @author Xin Chen
 * @version 1.0
 * @date 2016/12/15 10:55
 * @see 2016/12/15 10:55 Created
 ****************************************/
public class PageInfo implements Serializable {
    private static final long serialVersionUID = 7326349283768198763L;
    private int totalPageCount;
    private int totalRowCount;
    private int currentPageNum = 1;
    private int rowsOfPage = 10;
    private boolean countOfEverytime = true;

    public PageInfo() {
    }

    public PageInfo(String pageNum, String pageLength) {
        if(pageNum != null && pageNum.length() > 0) {
            this.currentPageNum = Integer.parseInt(pageNum);
        } else {
            this.currentPageNum = 1;
        }

        if(pageLength != null && pageLength.length() > 0) {
            this.rowsOfPage = Integer.parseInt(pageLength);
        } else {
            this.rowsOfPage = 15;
        }

    }

    public int getTotalPageCount() {
        return this.totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public int getTotalRowCount() {
        return this.totalRowCount;
    }

    public void setTotalRowCount(int totalRowCount) {
        this.totalRowCount = totalRowCount;
    }

    public int getCurrentPageNum() {
        return this.currentPageNum <= 0?1:this.currentPageNum;
    }

    public void setCurrentPageNum(int currentPageNum) {
        this.currentPageNum = currentPageNum;
    }

    public int getRowsOfPage() {
        return this.rowsOfPage <= 0?10:this.rowsOfPage;
    }

    public void setRowsOfPage(int rowsOfPage) {
        this.rowsOfPage = rowsOfPage;
    }

    public boolean isCountOfEverytime() {
        return this.countOfEverytime;
    }

    public void setCountOfEverytime(boolean countOfEverytime) {
        this.countOfEverytime = countOfEverytime;
    }

    public int getStartIndex() {
        return (this.getCurrentPageNum() - 1) * this.getRowsOfPage();
    }
}
